package com.advert.presentation.util.localization;

import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;

public class LabelsMap extends HashMap<String, String> {
    private Map<String, Label> map = new HashMap<String, Label>();

    public LabelsMap(Map<String, Label> map) {
        this.map = map;
    }

    public String get(Object key) {
        String retVal = "null";

        Label label = map.get(key);
        if (label != null) {
            retVal = label.getRu();
        } else if (key != null) {
            retVal = key.toString();
        }
        return retVal;
    }

    public String get(Object key, Object... parameters) {
        String retVal = get(key);
        try {
            retVal = MessageFormat.format(retVal, parameters);
        } catch (IllegalArgumentException e) {}
        return retVal;
    }
}
